<?php if ($action == 'update'): ?>
        <li><a class="return-button" href="javascript:void(0)" onclick="save({link:'<?php echo Yii::app()->request->getUrlReferrer() ?>'});">Save & Return</a></li>
        <li><a class="save-button" href="javascript:void(0)" onclick="save(null);">Save</a></li>

        <li><a class="cancel-button" href="index.php?r=invoices/cancel&invoice=<?= $model->invoice ?>">Cancel</a></li>
        <li><a class="delete-button"  href="index.php?r=invoices/cancel&delete=1&invoice=<?= $model->invoice ?>"
               onclick="return confirm('Are you sure to delete this item?')">Delete</a></li>
        <br/>



        <?php if ($model->quoteorg != NULL): ?>
            <li><a class="return-button"  href="index.php?r=invoices/update&invoice=<?= $model->quoteorg ?>">Back
                    to Quote</a></li>
        <?php endif ?>
        <?php
    if ($model->jobnumber != null)
    {
        echo '<li>';
        echo CHtml::link('Go to Job', array('/jobs/update', 'jobid' => $model->jobnumber), array('class' => 'return-button'));
        echo '</li>';
    }
?>
<?php
    if ($model->agreementno != null)
    {
        echo '<li>';
        echo CHtml::link('Back to Contract', array('/contracts/update', 'contractid' => $model->agreementno), array('class' => 'return-button'));
        echo '</li>';
    }
?>
        <?php if (InvoiceUnlocker::isInvoiceUnlocked($model->invoice) === false): ?>        
            <li><a class="add-button" href="javascript:void(0)" onclick="createInvoice('<?= $model->invoice ?>');">Create Invoice</a></li>
        <?php endif; ?>
        <br/><h5 style="padding-left:11px;"> Delivery</h5>
        <?php if ($model->location->disableemails): ?>
            <li><a  class="email-button"  href="#" id="mailForm" onclick="">E-Mail</a></li>
        <?php else: ?>
            <li><a  class="email-button"  href="#" id="mailEmpForm" onclick="">E-Mail</a></li>
        <?php endif; ?>
        <li><a class="print-button" href="javascript:void(0)" onclick="printNormal(true);">View/Print</a></li>
        <li><a class="print-button" href="javascript:void(0)" onclick="printWithAck(true);">View/Print  with Ack</a></li>
        <li><a class="print-button"  href="javascript:void(0)" onclick="printPackingList(true);">View/Print Packing List</a></li>
<?php elseif ($action == 'view'): ?>
        <li>
            <?php
            if (InvoiceUnlocker::canRenderUnlockButton())
            {
                echo CHtml::link('Unlock', array('invoices/unlockInvoice', 'invoice' => $model->invoice), array('class' => 'lock-button'));
            }
            ?>
        </li>

        <?php if ($model->quoteorg != NULL): ?>
            <li><a  class="return-button" href="index.php?r=invoices/update&invoice=<?= $model->quoteorg ?>">Back To Quote</a></li>
        <?php endif ?>
<?php
    if ($model->jobnumber != null)
    {
        echo '<li>';
        echo CHtml::link('Go to Job', array('/jobs/update', 'jobid' => $model->jobnumber), array('class' => 'return-button'));
        echo '</li>';
    }
?>
<?php
    if ($model->agreementno != null)
    {
        echo '<li>';
        echo CHtml::link('Back to Contract', array('/contracts/update', 'contractid' => $model->agreementno), array('class' => 'return-button'));
        echo '</li>';
    }
?>
        <li><a class="view-button" href="index.php?r=invoices/update&invoice=<?= $model->getInvoiceModel()->invoice ?>">View Invoice</a></li>
        
        <?php if(InvoiceUtil::getBillAmountForInvoiceAttachedToSaleOrders($model)!=$model->amountcharge):?>
            <li><a class="add-button" href="javascript:void(0)" onclick="createInvoiceWithoutSave('<?= $model->invoice ?>');">Create Invoice</a></li>
        <?php endif; ?>
            
        <li><a  class="delete-button" href="index.php?r=invoices/cancel&delete=1&invoice=<?= $model->invoice ?>"
                onclick="return confirm('Are you sure to delete this item?')">Delete</a></li>
<br/><h5 style="padding-left:11px;"> Delivery</h5> 
        <li><a  class="print-button"  href="javascript:void(0)" onclick="printNormal(false);">View/Print</a></li>
        
        <li><a class="print-button"  href="javascript:void(0)" onclick="printWithAck(false);">View/Print with Ack</a></li>
        
        <li><a  class="print-button"  href="javascript:void(0)" onclick="printPackingList(false);">View/Print Packing List</a></li>
        
        <?php if ($model->location->disableemails): ?>
            <li><a  class="email-button"  href="#" id="mailForm" onclick="">E-Mail</a></li>
        <?php else: ?>
            <li><a  class="email-button"  href="#" id="mailEmpForm" onclick="">E-Mail</a></li>
        <?php endif; ?>


    <?php endif; ?>

